package com.iyeed.jbpm06.demo03;

import java.util.concurrent.TimeUnit;

import org.jbpm.JbpmConfiguration;
import org.jbpm.JbpmContext;
import org.jbpm.graph.exe.ProcessInstance;
import org.junit.Test;

public class AsynchronousTest {

	@Test
	public void testAsynchronous() {
		JbpmContext jcontext = JbpmConfiguration.getInstance().createJbpmContext();
		try {
			ProcessInstance pi = jcontext.newProcessInstance("asynchronousprocess");
			pi.signal();
			System.out.println(pi.getRootToken().getNode().getName());
		} finally {
			jcontext.close();
		}
	}
	
	
	@Test
	public void testJob() throws InterruptedException {
		JbpmConfiguration.getInstance().getJobExecutor().start();
		TimeUnit.DAYS.sleep(1);
	}
	
	@Test
	public void testExecuteProcessInstance() {
		JbpmContext jcontext = JbpmConfiguration.getInstance().createJbpmContext();
		try {
			ProcessInstance pi = jcontext.getProcessInstance(830);
			pi.signal();
			System.out.println(pi.getRootToken().getNode().getName());
		} finally {
			jcontext.close();
		}
	}
	
}
